
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>YQL 2-Legged oAuth</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>

<!--there is no custom header content for this example-->

</head>

<body class="yui3-skin-sam  yui-skin-sam">

<h1>YQL 2-Legged oAuth</h1>

<div class="exampleIntro">
	<p>This example pairs the <a href="http://yuilibrary.com/gallery/show/oauth">YUI Gallery oAuth</a> module with YQL Query to make <a href="http://developer.yahoo.com/yql/console/?q=select%20title%2Cabstract%2Curl%2Csource%20from%20search.news%20where%20query%3D%22endangered%20species%22" title="YQL Console">an authenticated YQL request to Yahoo! Search's news search Web service.</a>.</p>
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<style>
#res .mod {
    background-color:white;
    border:1px solid black;
    padding:1em;
}
#res h3 {
    color: black;
}
#res cite {
    font-style: italic;
}
</style>


<div id="res">Loading data from YQL..</div>


<script>

YUI({ gallery: 'gallery-2010.08.11-20-39' }).use('node', 'yql', 'gallery-oauth', function(Y) {    

    //Using with YQL oAuth Gallery module
    Y.oAuth.ready(function() {
        
        Y.YQL('select title,abstract,url,source from search.news where query="endangered species"', function(r) {
            if (r.query.results) {
                var list = Y.Node.create('<ul></ul>');
                Y.each(r.query.results.result, function(v) {
                    list.append(Y.Lang.sub('<li><a href="{url}" target="_blank" title="{abstract}">{title}</a> (<cite>{source}</cite>)</li>', v));
                });
                Y.one('#res').set('innerHTML', '<h3>News Headlines</h3>').append(list);
            }
        }, {
            key: 'dj0yJmk9SXNaaTF2TGVMM1Q3JmQ9WVdrOVJGSlJRelpHTlRJbWNHbzlNelF6TlRjMk9EWXkmcz1jb25zdW1lcnNlY3JldCZ4PWMw',
            secret: 'f6cb68d25da294a584b541ff29da599a3f53db76',
            base: '://query.yahooapis.com/v1/yql?'
        });

    });

});
</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
